#include <pthread.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>

int gtid;
__thread int tid = -1;
int n = 0;

void *foo(void *) {
	n++;
	sleep(1);

	char buf1[10] = {'c', 'a', 'b', 'a', 'a', 'a', 'a', 'c', 'a', '\0'};
	char buf2[10] = {'a', 'a', 'b', 'a', 'a', 'a', 'a', 'b', 'a', '\0'};
	
	fprintf(stderr, "before memcpy buf1 %p %s, buf2 %s\n", (void *)buf1, buf1, buf2);

	void *p = memcpy(buf1, buf2, 10);

	fprintf(stderr, "after memcpy buf1 %p %p %s, buf2 %s\n", p, (void *)buf1, buf1, buf2);


}

int main() {
	int num = 10;

	pthread_t tids[10];

	for (int i = 0; i < num; i++) {
		pthread_create(&(tids[i]), NULL, foo, NULL);
	}

	for (int i = 0; i < num; i++) {
		pthread_join((tids[i]), NULL);
	}

	return 0;
}

